package common.util;

import java.util.List;

/**
 * @Author wangyue
 * @Version 3.0
 * @Date 2024-07-29
 */
public class ListUtils {

    public static <T> T getOrDefault(List<T> list, int index, T defaultValue) {
        if(list == null) return null;
        return index >= 0 && index < list.size() ? list.get(index) : defaultValue;
    }

    public static <T> T getOrNull(List<T> list, int index) {
        return getOrDefault(list, index, null);
    }

}
